package itheima.zuoye.test8;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        GoldenCard goldenCard = new GoldenCard("G001", 1000);
        SilverCard silverCard = new SilverCard("S001", 1000);
        payMoney(goldenCard);
    }

    public static void payMoney(Card CD) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请选择：1.金卡 2.银卡");
        int choice = sc.nextInt();
        switch (choice) {
            case 1:
                if (CD instanceof GoldenCard) {
                    GoldenCard goldenCard = (GoldenCard) CD;
                    goldenCard.pay();
                } else {
                    System.out.println("请选择正确的卡");
                }
                break;
            case 2:
                if (CD instanceof SilverCard) {
                    SilverCard silverCard = (SilverCard) CD;
                    silverCard.pay();
                    break;
                } else {
                    System.out.println("请选择正确的卡");
                }

            default:
                System.out.println("输入错误");
                return;

        }
    }

}

